package com.logistics.wms.service;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.logistics.utils.exception.MessageException;
import com.logistics.utils.tool.StringUtils;
import com.logistics.wms.entity.domain.WmsOrder;
import com.logistics.wms.mapper.WmsOrderMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.BitSet;
import java.util.List;

@DS("wms")
@Service
public class WmsOrderService {

    @Autowired
    private WmsOrderMapper wmsOrderMapper;

    /**
     * 根据标签码查询出库单信息
     * @param labelNumber
     * @return
     */
    public WmsOrder getWmsOrderLabelNumber(BigDecimal labelNumber) throws MessageException {
       labelNumber = labelNumber.subtract(new BigDecimal("8000000000"));
       List<WmsOrder> result = wmsOrderMapper.findOutOrderById(labelNumber);
       if(StringUtils.isNull(result) || result.size() == 0){
           throw new MessageException("物料编码不存在");
       }
       return result.get(0);
    }

}
